package com.gitee.xmhzzz.device.service.controller;

import com.gitee.xmhzzz.component.mqtt.client.api.IMqttApi;
import com.gitee.xmhzzz.component.mqtt.client.model.MqttReq;
import com.gitee.xmhzzz.component.mqtt.client.model.MqttResp;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName MqttController
 * @Description
 * @Author wzq
 * @Date 2024/1/22 16:31
 * @Version 1.0
 */
@RequestMapping("/web/mqtt")
@RestController
public class MqttController {

    @Autowired
    private IMqttApi IMqttApi;

    @PostMapping("/pub/tcp")
    public void pubTcp(){
        MqttReq mqttReq = new MqttReq();
        mqttReq.setTopic("topicA/001/in");
        Map<String, Object> map = Maps.newHashMap();
        map.put("1","o");
        mqttReq.setData(map);
        MqttResp mqttResp = IMqttApi.tcpPublish(mqttReq);
    }
}
